Skip to content

Conversation

@michaelbynum
Copy link
Contributor

@michaelbynum michaelbynum commented Aug 12, 2025

Summary/Motivation:

This PR refactors the gurobi interfaces to achieve two goals:

  • reduce duplicate code
  • use the new contrib.observer package

Changes proposed in this PR:

  • create a directory for gurobi now that there are 4 files
  • create a base class for all of the interfaces that use gurobipy, making the direct and persistent interfaces more consistent (e.g., tc_map, postsolve, solve, mipstart)
  • modify the persistent interface to use the contrib.observer package
  • add mipstart functionality to gurobi direct and gurobi minlp
  • add a minimum gurobipy version to the direct interface (addMConstr was not added until version 9)
  • simplified some of the persistent interface

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@codecov
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 65.59817% with 601 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.54%. Comparing base (8397f66) to head (43a864f).

Files with missing lines Patch % Lines
...contrib/solver/solvers/gurobi/gurobi_persistent.py 28.65% 488 Missing ⚠️
pyomo/contrib/observer/model_observer.py 90.70% 61 Missing ⚠️
...ontrib/solver/solvers/gurobi/gurobi_direct_base.py 83.84% 42 Missing ⚠️
...ntrib/solver/solvers/gurobi/gurobi_direct_minlp.py 66.66% 5 Missing ⚠️
...omo/contrib/solver/solvers/gurobi/gurobi_direct.py 95.23% 3 Missing ⚠️
pyomo/contrib/observer/component_collector.py 96.82% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3698      +/-   ##
==========================================
- Coverage   89.23%   85.54%   -3.70%     
==========================================
  Files         907      911       +4     
  Lines      104817   105454     +637     
==========================================
- Hits        93536    90213    -3323     
- Misses      11281    15241    +3960     
Flag Coverage Δ
builders 29.19% <25.58%> (+0.03%) ⬆️
default 85.37% <65.59%> (?)
expensive 35.69% <25.58%> (?)
linux ?
linux_other ?
osx ?
win ?
win_other ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants